home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11145 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  880 b 

  1. Path: news2.noc.netcom.net!news
  2. From: Tarang Deshpande <tarang@willows.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Q:  gets, getch, and stdin
  5. Date: Wed, 20 Mar 1996 08:41:59 -0800
  6. Organization: NETCOM Network Operations
  7. Message-ID: <31503557.2A97@willows.com>
  8. References: <DnoC9w.Eq9@info.uucp>
  9. NNTP-Posting-Host: daffy.willows.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  14.  
  15. Chris Redekop u wrote:
  16. > while ((ch = getch()) != '\r')
  17. >         ;
  18. > while ((ch = getchar()) != '\n')
  19. >         ;
  20.  
  21. The reason the \n works and \r does not is because \r means carriage
  22. return whereas \n mean new line.  \n means new line reguardless of
  23. what OS your using.  Some OS use <CR><LF> combination for \n other
  24. use only <LF> and so on.  So \r does not necessarily mean end of line,
  25. where as \n does.
  26.